﻿#include "dataobjectdialog.h"
#include "ui_dataobjectdialog.h"
#include <QTreeWidget>
#include <QUuid>

DataObjectDialog::DataObjectDialog(QWidget *parent) :
    QDialog(parent),
    ui(new Ui::DataObjectDialog)
{
    ui->setupUi(this);
}

DataObjectDialog::~DataObjectDialog()
{
    delete ui;
}

void DataObjectDialog::updateDialog(QTreeWidgetItem *pDataItem)
{
    if(nullptr == pDataItem)return;
    ui->lineEdit_Type->setText(pDataItem->data(0,Qt::DisplayRole).toString());
    ui->comboBox_MinCount->setCurrentText(pDataItem->data(1,Qt::DisplayRole).toString());
    ui->comboBox_MaxCount->setCurrentText(pDataItem->data(2,Qt::DisplayRole).toString());
    ui->lineEdit_Discribe->setText(pDataItem->data(2,Qt::DisplayRole).toString());

    return;
}

void DataObjectDialog::updateDateItem(QTreeWidgetItem *pDataItem)
{
    if(nullptr == pDataItem)return;

    pDataItem->setData(0,Qt::WhatsThisRole,QUuid::createUuid().toString());
    pDataItem->setData(0,Qt::DisplayRole,ui->lineEdit_Type->text());
    pDataItem->setData(1,Qt::DisplayRole,ui->comboBox_MinCount->currentText().toInt());
    pDataItem->setData(2,Qt::DisplayRole,ui->comboBox_MaxCount->currentText());
    pDataItem->setData(3,Qt::DisplayRole,ui->lineEdit_Discribe->text());

    pDataItem->setCheckState(0,Qt::Checked);

    return;
}
